package com.kotlin.hxh.ui.fragment.fourth

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.kotlin.hxh.R
import com.kotlin.hxh.base.BaseMainFragment
import com.kotlin.hxh.ui.fragment.fourth.child.AvatarFragment
import com.kotlin.hxh.ui.fragment.fourth.child.MeFragment

/**
 * @author huxh
 * @date 2018/12/17.
 */
class ZhihuFourthFragment : BaseMainFragment() {
    companion object {
        @JvmStatic
        fun newInstance(): ZhihuFourthFragment {
            val fragment = ZhihuFourthFragment()
            fragment.arguments = Bundle()
            return fragment
        }
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.zhihu_fragment_fourth, container, false)
    }


    override fun onLazyInitView(savedInstanceState: Bundle?) {
        super.onLazyInitView(savedInstanceState)
        if (findChildFragment(AvatarFragment::class.java) == null) {
            loadFragment()
        }
    }

    private fun loadFragment() {
        loadRootFragment(R.id.fl_fourth_container_upper, AvatarFragment.newInstance())
        loadRootFragment(R.id.fl_fourth_container_lower, MeFragment.newInstance())
    }

    fun onBackToFirstFragment(){
        _mBackToFirstListener?.onBackToFirstFragment()
    }
}